Check the comparison result of AWS CLI with colordiff command
When we use the AWS CLI command "Describe", the diff
command is used to make comparisons. In this post, we introduce the colordiff
commmand which highlights the differences using colours.
Install
On Macs, colordiff
can be installed using brew.
brew install colordiff
Colordiff is also available as a package on Linux/BSD.
colordiff | Availability of colordiff with your Linux/BSD distribution
Let's use colordiff
In the previous post, we checked the difference between the existing DB instance and the restored DB instance using diff
. This time, we check the result using colordiff
.
default
-u option (unified output format)
Display with the difference with [-] and [+] symbols.
-u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context. --label LABEL Use LABEL instead of file name. -p --show-c-function Show which C function each change is in. -F RE --show-function-line=RE Show the most recent line matching RE.
-c option (context output format)
Lines with changes are displayed. A few neighbouring lines before and after the changes are also shown for easier reference. Changes are indicated by [!].
-c -C NUM --context[=NUM] Output NUM (default 3) lines of copied context.
-y option (side by side format)
The output is presented side-by-side.
-y --side-by-side Output in two columns. -W NUM --width=NUM Output at most NUM (default 130) print columns. --left-column Output only the left column of common lines. --suppress-common-lines Do not output common lines.
Comparisons are easy to make because the output is displayed side-by-side. If we want to display more print columns, we use the-w
option, and if we only want to output the difference, we use the --suppress-common-lines
option.
TIPS
You can pipe to less -R
command.
colordiff -u file1 file2 | less -R
Conclusion
Colordiff displays the output with colours so we can easily compare the results of executing AWS CLIs. We recommend the use of colordiff
for convenience.